<template>
  <el-dialog :title="this.dataForm.realName + '_' + this.dataForm.mobilePhone + '-审核'" :close-on-click-modal="false"
    :visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="1350px">
    <el-row :gutter="15" class="">
      <el-form ref="elForm" :model="dataForm" size="mini" label-width="100px" label-position="right" :rules="rules">
        <el-col :span="24">
          <el-form-item label="抽佣比例" prop="drawProportion">
            <el-input-number :min="0" :max="9999" v-model="dataForm.drawProportion" />
          </el-form-item>
        </el-col>
        <el-row v-for="configItem in dataForm.comConfigs" :gutter="20" class="custom-row">


          <el-col :span="4">

            <el-form-item label="最小合伙人" prop="minNumber">
              <el-input-number :min="0" :max="9999" v-model="configItem.minNumber" />
            </el-form-item>

          </el-col>
          <el-col :span="4">

            <el-form-item label="最大合伙人" prop="maxNumber">
              <el-input-number :min="0" :max="9999" v-model="configItem.maxNumber" />
            </el-form-item>

          </el-col>

          <el-col :span="4">

            <el-form-item label="最小月份" prop="min">
              <el-input-number :min="0" :max="9999" v-model="configItem.min" />
            </el-form-item>

          </el-col>
          <el-col :span="4">

            <el-form-item label="最大月份" prop="max">
              <el-input-number :min="0" :max="9999" v-model="configItem.max" />
            </el-form-item>

          </el-col>
          <el-col :span="4">

            <el-form-item label="提成" prop="commission">
              <el-input-number :min="0" :max="9999" v-model="configItem.commission" />
            </el-form-item>

          </el-col>
        </el-row>


      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确 定</el-button>
    </span>
  </el-dialog>

</template>
<script>
import request from '@/utils/request'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
import { previewDataInterface } from '@/api/systemData/dataInterface'
export default {
  data() {
    return {
      visible: false,

      dataForm: {
        realName: undefined,
        mobilePhone: undefined,
        id: 0,

        drawProportion: 0
      },
      rules: {

      },


    }
  },
  created() {

  },
  methods: {

    goBack() {
      this.$emit('refresh')
    },
    init(id, userid, row) {

      this.dataForm.id = id || 0;
      this.dataForm.realName = row.realName;
      this.dataForm.mobilePhone = row.mobilePhone;
      this.dataForm.drawProportion = 0;
      this.dataForm.comConfig = "";
      this.dataForm.comConfigs = [];

      this.visible = true;
      this.$nextTick(() => {

        request({
          url: `/api/Jiushi/Userextend/ParentUserextendInfo/${userid}`,
          method: 'get',

        }).then((res) => {


          this.dataForm.drawProportion = res.data.drawProportion;
          this.dataForm.comConfig = res.data.comConfig;

          this.dataForm.comConfigs = JSON.parse(res.data.comConfig)

        })


      })
    },
    // 表单提交
    dataFormSubmit() {
      this.dataForm.comConfig = JSON.stringify(this.dataForm.comConfigs)

      request({
        url: `/api/Jiushi/Partner/Reviewer/${this.dataForm.id}`,
        method: 'Post',
        data: this.dataForm,
      }).then((res) => {
        this.$message({
          message: res.msg,
          type: 'success',
          duration: 1000,
          onClose: () => {
            this.visible = false;
            this.$emit('refresh', true);
          }
        })


      })
    }
  }
}
</script>